<?php
defined('IN_MAIN') or exit('Invalid Access!');
    
function add_banner_ad_view($id){
global $vars;
$db=$vars["db"];
$date=ndate("Y-m-d");
if(@mysql_num_rows(@mysql_query("select * from $db->banner_ad_stat where aid='$id' and cdate='$date'"))){
 $sql="update $db->banner_ad_stat set view=view+1 where aid='$id' and cdate='$date'";
}else{
 $sql="insert into $db->banner_ad_stat (aid, view, cdate) values ('$id', '1', '$date')";
}
$sql2="update $db->banner_ad set view=view+1 where id='$id'";
$a=@mysql_query($sql);
$a=@mysql_query($sql2) && $a;
return $a;
}

function add_banner_ad_click($id){
global $vars;
$db=$vars["db"];
$date=ndate("Y-m-d");
if(@mysql_num_rows(@mysql_query("select * from $db->banner_ad_stat where aid='$id' and cdate='$date'"))){
 $sql="update $db->banner_ad_stat set click=click+1 where aid='$id' and cdate='$date'";
}else{
 $sql="insert into $db->banner_ad_stat (aid, click, cdate) values ('$id', '1', '$date')";
}
$sql2="update $db->banner_ad set click=click+1 where id='$id'";
$a=@mysql_query($sql);
$a=@mysql_query($sql2) && $a;
return $a;
}
?>